Repository navigation
Fix offspring dimensions when crossover is disabled - #388
Draft
linjiaye929 wants to merge 2 commits into
Draft
linjiaye929 wants to merge 2 commits into
linjiaye929 wants to merge 2 commits into
Conversation
📊 Change summary3 files changed · +69 / −3 lines pie showData
title Lines changed per file (72 total)
"tests/test_no_crossover_offspring.py" : 63
"pygad/utils/engine.py" : 7
"pygad/utils/__init__.py" : 2
Per-file breakdown
|
The unchanged release-comparison test requires a submodule version bump when its source differs from the latest PyPI release. Keep the original fix and tests unchanged. Verified corrected wheel: 102 relevant regressions, 10 release-version checks, and 8 release-tool checks pass.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With crossover disabled, supported retention settings can produce the wrong number of offspring and fail during
GA.run().For a population of eight solutions:
num_parents_mating=2, keep_elitism=5requires three offspring but returns only two rows.num_parents_mating=6, keep_elitism=0, keep_parents=3requires five offspring but concatenates thirteen rows because the population slice has a negative endpoint.Change
Compare the required offspring count with the actual selected-parent count in the non-elitist branch. In the elitist short-offspring branch, retain the existing selected-parent prefix and fill only missing rows from the current population. Existing successful-path ordering is preserved. Add public-lifecycle regressions covering both cases, one-parent and zero-offspring boundaries, and mutation disabled or enabled with zero probability.
Validation
Using native source at
da4b0bf6ceaec0cadf9b354c37f34e5e317cbe2a, CPython 3.12.14, NumPy 2.5.4, cloudpickle 3.1.2 and pytest 9.2.0:test_keep_parents_elitism.py,test_crossover_mutation.py, andtest_operator_regressions.py.The full test suite, wheel build, optional deep-learning tests, other Python/NumPy versions, and hosted CI have not been verified. This PR is a draft.
AI assistance was used for investigation, implementation and test preparation.